package com.bjpowernode.p2padmin.user.controller;

import com.bjpowernode.p2padmin.user.model.RoleInfo;
import com.bjpowernode.p2padmin.user.service.RoleService;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * ClassName:RoleController
 * Package:com.bjpowernode.p2padmin.user.controller
 * Description:TODO描述
 *
 * @date:2020/4/8 16:30
 * @author:CC
 */

@Controller
public class RoleController {

    @Resource
    private RoleService roleService;

    @RequestMapping("/admin/roles")
    public String roles(Model model){

       List<RoleInfo> roleList= roleService.selectRolesAll();
       model.addAttribute("roleList",roleList);

       return "roles";
    }

    @RequestMapping("/admin/toDisPermission")
    public String toDisPermission(Integer roleId,Model model){

        model.addAttribute("roleId",roleId);
        return "disPermission";
    }

    @RequestMapping("/initPermissionTreeByRoleId")
    @ResponseBody
    public List<Map> initPermissionTreeByRoleId(Integer roleId){

        List<Map> treeNodes=roleService.initPermissionTreeByRoleId(roleId);
        return treeNodes;
    }


}
